(function (global, factory) {
    if (typeof exports === 'object') {
        module.exports = factory();
    } else if (typeof define === 'function') {
        // eslint-disable-next-line no-undef
        define(factory);
    } else {
        global.jackjs = factory();
    }
})(this, function () {
    return {
        core: {
            //判断是否为空1
            isEmpty(v) {
                switch (typeof v) {
                    case "undefined":
                        return true;
                    case "string":
                        if (v.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
                        break;
                    case 'boolean':
                        if (!v) return true;
                        break;
                    case 'number':
                        if (0 === v || isNaN(v)) return true;
                        break;
                    case 'object':
                        if (null === v || v.length === 0) return true;
                        for (var i in v) {
                            return false;
                        }
                        return true;
                }
                return false;
            },
            //判断是否为json字符串
            isJsonString(str) {
                try {
                    if (typeof JSON.parse(str) == "object") {
                        return true;
                    }
                } catch(e) {
                }
                return false;
            }
        },
        verify: {
            //判断是否为空
            verify_null(val) {
                if (val == '' || val ==undefined || val==null) {
                    return true;
                }
                return false;
            },
            //判定是否为手机号
            verify_mobile(val) {
                var re_phone = /^1[3456789]\d{9}$/;
                if (!re_phone.test(val)) {
                    return true;
                }
                return false;
            }
        },
        other: {
            //遮盖手机号
            coverMobile(mobile) {
                if (Number(mobile) && String(mobile).length === 11) {
                    mobile = String(mobile)
                    var reg = /^(\d{3})\d{4}(\d{4})$/
                    return mobile.replace(reg, '$1****$2')
                } else {
                    return mobile
                }
            },
            //时间戳转换时间
            time_format (value) {
                var date = new Date(value) //时间戳为10位需*1000，时间戳为13位的话不需乘1000
                var Y = date.getFullYear() + '-'
                var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'
                var D = date.getDate() + ' '
                var h = date.getHours() + ':'
                var m = date.getMinutes() + ':'
                var s = date.getSeconds()
                return Y+M+D+h+m+s
            },
            //获取get参数
            getQueryString (name) {
                const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
                const r = window.location.search.substr(1).match(reg)
                if (r !== null) return unescape(r[2])
                return null
            }
        }

    }
})
